package actions;

import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.RowSet;

import model.ReviewerModel;
import model.StudentModel;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import db.DbException;

public class AccountAction extends Action {
    // is there a way to make this global for the application
    public final int REVIEW_PROCESS_THRESHOLD = 3;

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws DbException {
        ArrayList<ArrayList> workload = null;

        // if user is a reviewer find all ungraded applications
        if(request.isUserInRole("reviewer")){
            String reviewer = request.getUserPrincipal().getName();
            int reviewerid = ReviewerModel.fetchIdByUsername(reviewer);
            workload = ReviewerModel.getWorkload(reviewerid);
            request.setAttribute("workload", workload);
        }
        
                        
        return mapping.findForward("success");
    }
}
